package com.ttl.bc.ar.reqconfirm.bean;

import org.displaytag.decorator.TableDecorator;

import com.ttl.bc.ap.purchaseorder.bean.BCPurchaseOrderSubShow2Bean;

public class BCReqConfirmSubShowDecorator extends TableDecorator {
		
	public String getIttl_status() {
		
//		BCReqConfirmSubShowBean obj = (BCReqConfirmSubShowBean)getCurrentRowObject();
		
		BCPurchaseOrderSubShow2Bean obj = (BCPurchaseOrderSubShow2Bean)getCurrentRowObject();
		
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			return "ขอซื้อ"+obj.getIttl_status();
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
			return "รอซื้อ"+obj.getIttl_status();
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("2")) {
			return "ซื้อแล้ว"+obj.getIttl_status();
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("3")) {
			return "จ่ายแล้ว"+obj.getIttl_status();			
		}else {
			return "ยกเลิก"+obj.getIttl_status();
		}
	}
	
	public String getMode() {		
		
//		BCReqConfirmSubShowBean obj = (BCReqConfirmSubShowBean)getCurrentRowObject();
		BCPurchaseOrderSubShow2Bean obj = (BCPurchaseOrderSubShow2Bean)getCurrentRowObject();
		String docNo = obj.getDocNo();						
		String stkDocNo = obj.getStkReqNo();
		
		String print = "";
		String po = "";
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			po = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=create&docNo="+stkDocNo+"\">สร้างใบ PO</a>  ";

		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
			
//			if(docNo!=null) {
				po =  "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=edit&docNo="+stkDocNo+"&poDocNo="+docNo+"\">แก้ไข</a> | ";						
				po += "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=cancel&docNo="+stkDocNo+"&poDocNo="+docNo+"\">ยกเลิก</a> | ";			
				print = "<a href=\"/ittl/purchaseOrder/purchaseOrder.do?mode=print&docNo="+docNo+"&stkDocNo="+stkDocNo+"\" target=\"_blank\">Print</a>";
//			}
						
		}else if (obj.getIttl_status()!=null && (obj.getIttl_status().equals("2")||obj.getIttl_status().equals("3")) ) {
			po = "บันทึกอินวอยซ์แล้ว ";
			
		}else {
			po = "ยกเลิกขอซื้อ";
		}
		
		return "<center>"+po+print+"</center>";						
	}
}
